//
//  DetailTableViewController.m
//  壳牌喜力促销积分商城
//
//  Created by xrd on 15/3/17.
//  Copyright (c) 2015年 xrd. All rights reserved.
//

#import "DetailTableViewController.h"
#import "DetailTableViewCell.h"
#import "DetailMode.h"

#import "ShopingViewController.h"

//#import "GoodsDetailTC.h"

@interface DetailTableViewController () <UITableViewDataSource>

@property(nonatomic,strong)NSMutableArray *detailModes;//用来保存所有的数据

@end

@implementation DetailTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.rowHeight = 90;
    
    
}
- (NSArray *)detailModes
{
if (_detailModes == nil)
{
    NSArray *dictarray  =  [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"tgs"ofType:@"plist"]];
    
    NSMutableArray *dtArray = [NSMutableArray array ];
    for (NSDictionary   * dict in dictarray) {
        DetailMode *dt = [DetailMode detailModeWithDict:dict];
        
        [dtArray addObject:dt];
        
    }
    _detailModes = [dtArray copy];
    
}
    return  _detailModes;
    


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//#warning Potentially incomplete method implementation.
//    // Return the number of sections.
//    return 0;
//}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.detailModes.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    //1.创建cell
    DetailTableViewCell *cell = [DetailTableViewCell cellWithTableView:tableView];
    
//    2.给cell 进行传递数据模式
    cell.detailMode = self.detailModes[indexPath.row];
    
    
    
    
    return cell;
}



#pragma mark - tableView delegate 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

 ShopingViewController *shoping = [[ShopingViewController alloc]init];
    shoping.title = @"商品详情";
    [self.navigationController  pushViewController:shoping animated:YES];
    


}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/



@end
